//
//  NearbyTableViewCell.m
//  CommonFrame
//
//  Created by Bang-guo on 15/7/21.
//  Copyright (c) 2015年 guobang. All rights reserved.
//

#import "NearbyTableViewCell.h"

@implementation NearbyTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        [self createSubViews];
    }
    
    return self;
}

-(void)createSubViews {
    //rating ; //星星
    //visited_count ; //去过
    //name ; //景点名
    //distance ; // 距离
    //recommended_reason ; // 介绍
    //tips_count ; // 点评
    //cover_s ; //图片
    BaseView *backV = [[BaseView alloc] initWithFrame:CGRectMake(10, 5, WIDTH - 20, 170)];
    backV.backgroundColor = [UIColor colorWithRed:230 / 255.0 green:220 / 255.0 blue:220 / 255.0 alpha:1];
    [self.contentView addSubview:backV];
    backV.layer.masksToBounds = YES;
    backV.layer.cornerRadius = 10;
    
    self.cover_sImageV = [[UIImageView alloc] initWithFrame:CGRectMake(10, 35, 100, 100)];
//    self.cover_sImageV.backgroundColor = [UIColor greenColor];
    [backV addSubview:self.cover_sImageV];
    
    self.nameL = [[BaseLabel alloc] initWithFrame:CGRectMake(30, 0, WIDTH - 85, 35)];
//    self.nameL.text = @"1";
//    self.nameL.backgroundColor = [UIColor redColor];
    self.nameL.font = [UIFont systemFontOfSize:20.0];
//    self.nameL.textAlignment = NSTextAlignmentCenter;
    [backV addSubview:self.nameL];
    
    self.recL = [[BaseLabel alloc] initWithFrame:CGRectMake(backV.frame.size.width - 32, 0, 30, 30)];
    self.recL.backgroundColor = [UIColor orangeColor];
    self.recL.text = @"荐";
    self.recL.textColor = [UIColor whiteColor];
    self.recL.textAlignment = NSTextAlignmentCenter;
    self.recL.layer.masksToBounds = YES;
    self.recL.layer.cornerRadius = 15;
    [backV addSubview:self.recL];
    
    self.ratingL = [[BaseLabel alloc] initWithFrame:CGRectMake(self.cover_sImageV.frame.origin.x + self.cover_sImageV.frame.size.width + 5, self.cover_sImageV.frame.origin.y, WIDTH - 150, 30)];
//    self.ratingL.backgroundColor = [UIColor blueColor];
    [backV addSubview:self.ratingL];
    
    self.tips_countL = [[BaseLabel alloc] initWithFrame:CGRectMake(self.ratingL.frame.origin.x, self.ratingL.frame.origin.y + self.ratingL.frame.size.height + 5, self.ratingL.frame.size.width, 30)];
//    self.tips_countL.backgroundColor = [UIColor purpleColor];
    [backV addSubview:self.tips_countL];
    
    self.distanceL = [[BaseLabel alloc] initWithFrame:CGRectMake(self.ratingL.frame.origin.x, self.tips_countL.frame.origin.y + self.tips_countL.frame.size.height + 5, self.ratingL.frame.size.width, 30)];
//    self.distanceL.backgroundColor = [UIColor yellowColor];
    [backV addSubview:self.distanceL];
    
    self.recommended_reasonL = [[BaseLabel alloc] initWithFrame:CGRectMake(10, backV.frame.size.height - 35, backV.frame.size.width - 20, 35)];
//    self.recommended_reasonL.backgroundColor = [UIColor redColor];
    self.recommended_reasonL.textAlignment = NSTextAlignmentCenter;
    [backV addSubview:self.recommended_reasonL];
    
}

-(void)setNearby:(NearbyModle *)nearby {
    
    if (_nearby != nearby) {
        
        _nearby = nearby;
        
    }
    
    [self.cover_sImageV sd_setImageWithURL:[NSURL URLWithString:nearby.cover_s] placeholderImage:[UIImage imageNamed:@"icon1024.png"]];
    self.nameL.text = nearby.name;
    self.ratingL.text = [NSString stringWithFormat:@"推荐指数:%@", nearby.rating];
    self.tips_countL.text = [NSString stringWithFormat:@"%@ 点评", nearby.tips_count];
    self.recommended_reasonL.text = nearby.recommended_reason;
    float f = [[NSString stringWithFormat:@"%@", nearby.distance] floatValue];
    self.distanceL.text = [NSString stringWithFormat:@"距我 %.0f KM | %@ 人去过", f, nearby.visited_count];

    
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
